package com.lottery.im.module.chat.adapter;

import android.support.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lottery.im.R;
import com.lottery.im.api.result.entity.RedPackets;
import com.lottery.im.util.DateUtils;
import java.text.DecimalFormat;
import java.util.List;

public class RedPacketsRecordAdapter extends BaseQuickAdapter<RedPackets, BaseViewHolder> {

  // 0 收到的 1 发出的
  private int requestType = 0;

  public RedPacketsRecordAdapter(@Nullable List<RedPackets> data) {
    super(R.layout.item_redpacketsrecord, data);
  }

  @Override protected void convert(BaseViewHolder helper, RedPackets item) {

    if (requestType == 0) {
      helper.setText(R.id.tv_name, item.getUserName());
    } else {
      if (item.getRedPacketsType() == 0) {
        helper.setText(R.id.tv_name, "普通红包");
      } else {
        helper.setText(R.id.tv_name, "随机红包");
      }
    }

    helper.setText(R.id.tv_time, DateUtils.strAllTime2Format(item.getCreateTime()));
    DecimalFormat df = new DecimalFormat("#0.00");
    helper.setText(R.id.tv_money, df.format(item.getMoney()) + "元");
  }

  public int getRequestType() {
    return requestType;
  }

  public void setRequestType(int requestType) {
    this.requestType = requestType;
  }
}
